package com.gouwudai.gobbs.dao.impl;

import org.apache.log4j.Logger;

import com.gouwudai.gobbs.dao.ITopicContentDAO;
import com.gouwudai.gobbs.pojo.TbbsTopicContent;
import com.litt.core.exception.DBException;

public class TopicContentDAOImpl extends BaseDAOImpl implements ITopicContentDAO 
{
	private static final Logger logger = Logger.getLogger(TopicContentDAOImpl.class);	
	private static final String BUSI_NAME = "主题内容信息";
	
	public void save(TbbsTopicContent tbbsTopicContent)
	{    		
		super.saveObject(tbbsTopicContent);		
	}
	
	public TbbsTopicContent load(Integer id)
	{
		return (TbbsTopicContent)super.loadObject(TbbsTopicContent.class, id);
	} 
	
	public TbbsTopicContent loadByTopicReId(Integer topicReId)
	{
		String hql = "from TbbsTopicContent where topicReId="+topicReId;
		return (TbbsTopicContent)super.uniqueResultHql(hql);
	} 	
	
    public void update(TbbsTopicContent tbbsTopicContent)
    {
    	StringBuilder hql = new StringBuilder();
        hql.append("update TbbsTopicContent set content=?"); 
        hql.append(", contentUserPen=?");        
        hql.append(", contentEmail=?");
        hql.append(", contentCopyright=?");
        hql.append(" where contentId=?");
        super.updateObject(hql.toString(), new Object[]{
        	tbbsTopicContent.getContent(),
        	tbbsTopicContent.getContentUserPen(),        	
        	tbbsTopicContent.getContentEmail(),
        	tbbsTopicContent.getContentCopyright(),
        	tbbsTopicContent.getContentId()});

    }
    
    public void delete(Integer contentId)
    {
        super.deleteObject(TbbsTopicContent.class.getName(),"contentId",contentId);
    }
    
}
